package tt.lab.designparttern.singleton;

public class SingleInstance {
	private static SingleInstance instance;
	private int i;
	private SingleInstance() {}

	public static synchronized SingleInstance getInstance() {
		if (instance == null)
			instance = new SingleInstance();
		return instance;
	}
	
	public synchronized int  getNextVal(){
		return i++;
	}
	
	public synchronized void test(){
		AA a = new AA();
		System.out.println("SingleInstance.test(): "+a);
	}
}
class AA{}
